package 每日一题;

public class 最大单词长度乘积 {
    public int maxProduct(String[] words) {
        int[] masks = new int[words.length];
        for (int i = 0; i < words.length; i++) {
            int t = 0;
            for (int j = 0; j < words[i].length(); j++) {
                t |= (1<<(words[i].charAt(j)-'a'));
            }
            masks[i] = t;
        }
        int res=0;
        for (int i = 0; i < words.length-1; i++) {
            for (int j = i+1; j < words.length; j++) {
                if ((masks[i]&masks[j])==0){
                   res = Math.max(res,words[i].length()*words[j].length());
                }
            }
        }
        return res;
    }
}
